<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class bagian_jenis_aktifitas_model extends CI_Model {

    function __construct() 
	{
        parent::__construct();
        $this->CI = get_instance();
    }
	
	function selectone($id_bagian_jenis_aktifitas) 
	{
		$this->db->select("*");
        $this->db->from('bagian_jenis_aktifitas');
		$this->db->join('jenis_aktifitas AS JA','bagian_jenis_aktifitas.id_jenis_aktifitas = JA.id_jenis_aktifitas','left');
		$this->db->where('id_bagian_jenis_aktifitas', $id_bagian_jenis_aktifitas);        
        $query = $this->db->get();
        return $query;
	}
	
	function selectone2($id_satuan_jenis_aktifitas) 
	{
		$this->db->select("*");
        $this->db->from('satuan_jenis_aktifitas');
		$this->db->join('bagian_jenis_aktifitas AS BJA','satuan_jenis_aktifitas.id_bagian_jenis_aktifitas = BJA.id_bagian_jenis_aktifitas','left');
		$this->db->where('id_satuan_jenis_aktifitas', $id_satuan_jenis_aktifitas);        
        $query = $this->db->get();
        return $query;
	}
			
	function get_nama_satuan_aktifitas($id_bagian_jenis_aktifitas) 
	{
        //Build contents query
		$this->db->select('s.*, ks.*');
		$this->db->from('satuan_jenis_aktifitas ks');
		$this->db->join('bagian_jenis_aktifitas as s', 'ks.id_bagian_jenis_aktifitas = s.id_bagian_jenis_aktifitas', 'left');
		$this->db->where('ks.id_bagian_jenis_aktifitas', $id_bagian_jenis_aktifitas);
		$this->CI->flexigrid->build_query();		
		
        //Get contents
        $return['records'] = $this->db->get();

        //Build count query
        $this->db->select('s.*, ks.*');
		$this->db->from('satuan_jenis_aktifitas ks');
		$this->db->join('bagian_jenis_aktifitas as s', 'ks.id_bagian_jenis_aktifitas = s.id_bagian_jenis_aktifitas', 'left');
		$this->db->where('ks.id_bagian_jenis_aktifitas', $id_bagian_jenis_aktifitas);
		$this->CI->flexigrid->build_query(FALSE);

        $return['record_count'] = $this->db->count_all_results();

        //Return all
        return $return;
    }
		
	function get_data_bagian_jenis_aktifitas_ja()
	{
		//Select table name
		$table_name = "bagian_jenis_aktifitas";
		
		//Build contents query
		$this->db->select('*')->from($table_name);
		$this->db->join('jenis_aktifitas AS H','bagian_jenis_aktifitas.id_jenis_aktifitas = H.id_jenis_aktifitas','left');
		$this->CI->flexigrid->build_query();
		
		//Get contents
		$return['records'] = $this->db->get();
		
		//Build count query
		$this->db->select('*')->from($table_name);
		$this->db->join('jenis_aktifitas AS H','bagian_jenis_aktifitas.id_jenis_aktifitas = H.id_jenis_aktifitas','left');
		$this->CI->flexigrid->build_query(FALSE);
		
		$return['record_count'] = $this->db->count_all_results();
	
		//Return all
		return $return;
	}	
	
	function get_nama_satuan_bagian_aktifitas() 
	{
		//Select table name
		$table_name = "satuan_jenis_aktifitas";
		
		//Build contents query
		$this->db->select('*')->from($table_name);
		$this->db->join('bagian_jenis_aktifitas AS P','satuan_jenis_aktifitas.id_bagian_jenis_aktifitas = P.id_bagian_jenis_aktifitas','left');
		// $this->db->join('jenis_aktifitas AS H','bagian_jenis_aktifitas.id_jenis_aktifitas = H.id_jenis_aktifitas','left');
		// $this->db->where('id_bagian_jenis_aktifitas',$id_bagian_jenis_aktifitas);
		$this->CI->flexigrid->build_query();
		
		//Get contents
		$return['records'] = $this->db->get();
		
		//Build count query
		$this->db->select('*')->from($table_name);
		$this->db->join('bagian_jenis_aktifitas AS P','satuan_jenis_aktifitas.id_bagian_jenis_aktifitas = P.id_bagian_jenis_aktifitas','left');
		// $this->db->join('jenis_aktifitas AS H','bagian_jenis_aktifitas.id_jenis_aktifitas = H.id_jenis_aktifitas','left');
		// $this->db->where('id_bagian_jenis_aktifitas',$id_bagian_jenis_aktifitas);
		$this->CI->flexigrid->build_query(FALSE);
		
		$return['record_count'] = $this->db->count_all_results();
	
		//Return all
		return $return;
	
	
		/*
		$this->db->select("*");
        $this->db->from('satuan_jenis_aktifitas');
        $this->db->join('bagian_jenis_aktifitas AS P','satuan_jenis_aktifitas.id_bagian_jenis_aktifitas = P.id_bagian_jenis_aktifitas','left');
		$this->db->where('id_bagian_jenis_aktifitas',$id_bagian_jenis_aktifitas);
        $query = $this->db->get();
        return $query;
		*/
	}
	
	
	
}

?>